package com.swu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.swu.dto.DiseaseDictionaryQueryDTO;
import com.swu.mapper.DiseaseDictionaryMapper;
import com.swu.po.DiseaseDictionary;
import com.swu.service.DiseaseDictionaryService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 疾病字典表 服务实现类
 * </p>
 *
 * @author 勾新杰
 * @since 2025-06-07
 */
@Service
public class DiseaseDictionaryServiceImpl extends ServiceImpl<DiseaseDictionaryMapper, DiseaseDictionary> implements DiseaseDictionaryService {

    @Override
    public Page<DiseaseDictionary> pageQuery(DiseaseDictionaryQueryDTO queryDTO) {
        LambdaQueryWrapper<DiseaseDictionary> queryWrapper = new LambdaQueryWrapper<>();
        
        // 添加查询条件
        if (StringUtils.isNotBlank(queryDTO.getDiseaseCode())) {
            queryWrapper.like(DiseaseDictionary::getDiseaseCode, queryDTO.getDiseaseCode());
        }
        if (StringUtils.isNotBlank(queryDTO.getDiseaseName())) {
            queryWrapper.like(DiseaseDictionary::getDiseaseName, queryDTO.getDiseaseName());
        }
        
        // 创建分页对象
        Page<DiseaseDictionary> page = new Page<>(queryDTO.getPageNum(), queryDTO.getPageSize());
        
        // 执行查询
        return this.page(page, queryWrapper);
    }
}
